/*
 * Copyright (c) 2011 Salzburg Research.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package at.newmedialab.skwrl.model;

import at.newmedialab.skwrl.api.SKWRLBackend;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Add file description here!
 * <p/>
 * User: sschaffe
 */
public class Program<Node> implements SKWRLConstruct<Node>{

    private Long id;


    private String name;

    private String description;

    private Map<String,String> namespaces;

    private Set<Rule<Node>> rules;



    public Program() {
        rules = new HashSet<Rule<Node>>();
        namespaces = new HashMap<String, String>();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Map<String, String> getNamespaces() {
        return namespaces;
    }

    public void setNamespaces(Map<String, String> namespaces) {
        this.namespaces = namespaces;
    }

    public void addNamespace(String prefix, String uri) {
        getNamespaces().put(prefix,uri);
    }


    public Set<Rule<Node>> getRules() {
        return rules;
    }

    public void setRules(Set<Rule<Node>> rules) {
        this.rules = rules;
    }


    public void addRule(Rule rule) {
        getRules().add(rule);
    }


    public String toSKWRLString(SKWRLBackend<?,Node> backend) {
        String s = "";
        for(Rule<Node> rule : getRules()) {
            s += rule.toSKWRLString(backend);
            s += "\n";

        }
        return s;
    }

}
